<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="${backPath}/images/skin.css" rel="stylesheet" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<style type="text/css">
<!--
body {
	font-size:12px;
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
	background-color: #EEF2FB;
}
-->
</style>
<script type="text/javascript" language="javascript" src="${cardPath}/common/common.js"></script>
<script type="text/javascript" language="javascript">

	

	//获得voteForm
	function getVoteForm(){
		return document.getElementById("voteForm");
	}

	//增加选票答案行
	function addVoteAnswerTR(){
		var table = document.getElementById("answersTable");
		var rowsCount = table.rows.length;		
		var tr = table.insertRow(rowsCount);
		var td1 = tr.insertCell(0);
		td1.innerHTML = "&nbsp";		
		var td2 = tr.insertCell(1);
		var td2Txt = "<div align=\"left\">";
		td2Txt += "<input type=\"text\" class=\"left_txt\" name=\"answers\" id=\"answers\" style=\"height:20px;width:400px\"/>";
        td2Txt += "</div>";
		td2.innerHTML = td2Txt;				
	}

	//删除选票答案行
	function removeVoteAnswerTR(){		
		var table = document.getElementById("answersTable");
		var rowsCount = table.rows.length;			
		if(rowsCount == 4) return;	
		table.deleteRow(rowsCount-1);
	}

	//增加选票
	function addVote(){
		//检查题干
		var title = document.getElementById("vote.title").value.trim();
		if(title.length == 0){
			alert("投票问题不能为空!");
			return false;
		}
		var arrAnswers = document.getElementsByName("answers");
		for(var i=0;i<arrAnswers.length;i++){
			if(arrAnswers[i].value.trim().length == 0){
				alert("投票问题的答案提供的不完整，请检查！");
				return false;
			}
		}		
		var voteForm = getVoteForm();		
		voteForm.action = "${backPath}/club/addVote.action";
		voteForm.submit();
	}

	//跳转至选票列表页
	function backToVoteList(){
		var voteForm = getVoteForm();		
		voteForm.action = "${backPath}/club/listVotes.action";
		voteForm.submit();
	}
</script>
</head>
<body>
<form id="voteForm" action="" method="post">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="${backPath}/images/mail_leftbg.gif"><img src="${backPath}/images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="${backPath}/images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">投票管理</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="${backPath}/images/mail_rightbg.gif"><img src="${backPath}/images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="${backPath}/images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td colspan="2" valign="top">&nbsp;</td>      
      </tr>
      <tr>
        <td colspan="2" valign="top">
          <!--HTML-->
          <table class=main_tab id=mainTable cellspacing=0
cellpadding=0 width=100% border=0>
            <!--TBODY-->
            <tbody>
              <tr>
                <td valign=top>
                <table width="98%" height="88" border=0 align="center" cellpadding=0 cellspacing=0>
                  <tbody>
                    <tr>
                      <td height="5" colspan="4"></td>
                    </tr>
                    <tr>
                      <td width="2%" bgcolor="#FAFBFC">&nbsp;</td>
                      <td height="25" colspan="3" align="center" valign="middle" bgcolor="#FAFBFC"><table width="100%" border="0" cellspacing="5" cellpadding="5">
                        <tr>
                          <td width="25%">&nbsp;</td>
                          <td>&nbsp;</td>
                          <td width="26%">&nbsp;</td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td><fieldset>
                          <legend>投票问题</legend>                          
                           <div align="center">
                             <table width="100%" border="0" cellspacing="0" cellpadding="0">
                               <tr>
                                 <td width="9%">&nbsp;</td>
                                 <td width="91%">&nbsp;</td>
                               </tr>
                               <tr>
                                 <td>&nbsp;</td>
                                 <td>
                                   <div align="left">
                                     <textarea name="vote.title" id="vote.title"  rows="5" style="width:400px" class="left_txt"></textarea>
                                     </div></td>
                               </tr>
                               <tr>
                                 <td>&nbsp;</td>
                                 <td height="15">&nbsp;</td>
                               </tr>
                             </table>
                           </div>
                          </fieldset>
                          <label></label></td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                        	<td>&nbsp;</td>
                        	<td colspan="2">                        		
                        		是否投票项:
                        		<input type="checkbox" id="isVoted" name="isVoted" />
                        	</td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td rowspan="3" valign="top">
                          <fieldset>
                            <legend> 备选答案</legend>
                      
                            <table id="answersTable" width="420px" border="0" cellspacing="2" cellpadding="0">
                       
  <tr>
    <td>&nbsp;</td>
    <td></td>
  </tr>
  <tr>
    <td width="6%">&nbsp;</td>
    <td><label></label>
    <div align="right">
      <input type="button" class="left_txt" name="btnAddAnsw" id="btnAddAnsw" value="增加" onclick="addVoteAnswerTR()"/>
      <input type="button" class="left_txt" name="btnRemove" id="btnRemove" value="减少" onclick="removeVoteAnswerTR()"/>
</div></td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      
        <div align="left">
          <input type="text" name="answers" class="left_txt" id="answer" style="height:20px;width:400px"/>
        </div></td>
    </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
      <div align="left">
        <input type="text" name="answers" class="left_txt" id="answer" style="height:20px;width:400px"/>
        </div></td>
  </tr>
</table>
                            </fieldset>                          </td>
                          <td>&nbsp;</td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td>&nbsp;</td>
                        </tr>
                        <tr>
                          <td>&nbsp;</td>
                          <td>&nbsp;</td>
                        </tr>
                        
                        
                        
                      </table></td>
                    </tr>
                    <tr>
                      <td bgcolor="#FAFBFC">&nbsp;</td>
                      <td width="40%" height="25" bgcolor="#FAFBFC">&nbsp;</td>
                      <td width="40%" bgcolor="#FAFBFC">
                      	<input type="button" name="save" id="save" class="left_txt" value="保存"  onclick="addVote()"/>
                      	<input type="submit" name="reset" id="reset" class="left_txt" value="返回选票列表页" onclick="backToVoteList()"/>
                      </td>
                      <td width="40%" height="25" bgcolor="#FAFBFC" align="left">                        
                        
                      </td>                      
                    </tr>
                    <tr>
                      <td height="5" colspan="4"></td>
                    </tr>
                  </tbody>
                </table></td>
              </tr>
            </tbody>           
          </table></td>
      </tr>
    </table></td>
    <td background="${backPath}/images/mail_rightbg.gif">&nbsp;</td>
  </tr>
  <tr>
    <td valign="bottom" background="${backPath}/images/mail_leftbg.gif"><img src="${backPath}/images/buttom_left2.gif" width="17" height="17" /></td>
    <td background="${backPath}/images/buttom_bgs.gif"><img src="${backPath}/images/buttom_bgs.gif" width="17" height="17"></td>
    <td valign="bottom" background="${backPath}/images/mail_rightbg.gif"><img src="${backPath}/images/buttom_right2.gif" width="16" height="17" /></td>
  </tr>
</table>
</form>
</body>
</html>